﻿<?php
  echo '</td>'
              . '</tr>'
							. '<tr> <td>Podategoria</td><td><select name="podkategoria" class="styled" size="8" >';
			//tworzenie select - kategoria       
      $query = "SELECT * FROM ucat" ;
			$result=mysql_query($query);
			while ($r=mysql_fetch_array($result))
      {
					$n =$r['ID']; 
					echo '
					<optgroup label="'.$r['name'].'">';
					$query2 = "SELECT * FROM `cat` WHERE `id_ucat` =$n" ;     
					$result2=mysql_query($query2);
					while ($r2=mysql_fetch_array($result2))
					{
						echo '<option value="'.$r['ID'].'">'.$r2['name'].'</option>
						';
					}
					echo '</optgroup>';		
			}
	echo      '</select>';
							
?>